

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>My JSP 'viewAdmin.jsp' starting page</title>
<link href="../css/bootstrap-cerulean.css" rel="stylesheet">
<link href="../css/charisma-app.css" rel="stylesheet">
<style type="text/css">
body {
	padding-bottom: 40px;
}

.sidebar-nav {
	padding: 9px 0;
}
</style>
	<script src="http://lib.sinaapp.com/js/jquery/2.2.4/jquery-2.2.4.min.js"></script>
	<script src="../js/common/public.js"></script>
	<script src="../js/base64.js"></script>
	<script type="text/javascript">
        $(document).ready(function () {
            var urlMsg = parseUrl(window.location.search);
            $("#token").val(urlMsg.token);
            if (urlMsg.token != null) {
                var token = decode(urlMsg.token);
                token=token.substring(0,token.length-1);
            }

			var html = $.ajax({
                type: "POST",
                url: "http://localhost:1068/admin/student/findStudentByClassNumber?token="+token+"&classNumber="+urlMsg.classNumber,
                async: false
            }).responseText;
            var result = eval('(' + html + ')');
            if (result.code != 200) {
                alert(result.msg)
            } else {
                for (index in result.data){
                    addStudentTable(result.data[index].studentNumber,
                        result.data[index].classNumber,
                        result.data[index].studentNumber,
                        result.data[index].name,
                        result.data[index].score,
                        result.data[index].duty);
                   $('#scoreDatils'+ result.data[index].studentNumber+'').attr('href','studentScoreList.html?token='+urlMsg.token+'&studentNumber='+result.data[index].studentNumber)
                    $('#updateStudent'+ result.data[index].studentNumber+'').attr('href','editStudent.html?token='+urlMsg.token+'&studentNumber='+result.data[index].studentNumber);
                    $('#addScore'+ result.data[index].studentNumber+'').attr('href','addStudentScore.html?token='+urlMsg.token+'&studentNumber='+result.data[index].studentNumber);

                }
            }
        });
        function deleteStudent(id,a) {
            if(window.confirm('删除操作不可逆，确定要删除吗？')){
                var urlMsg = parseUrl(window.location.search);
                $("#token").val(urlMsg.token);
                if (urlMsg.token != null) {
                    var token = decode(urlMsg.token);
                    token=token.substring(0,token.length-1);
                }
                var html = $.ajax({
                    type: "DELETE",
                    url: "http://localhost:1068/admin/student/deleteStudent?token="+token+"&studentNumber="+id,
                    async: false
                }).responseText;
                var result = eval('(' + html + ')');
                if (result.code != 200) {
                    alert(result.msg)
                } else {
                    alert("删除成功！")
                    $(a).parent().parent().remove();
                }
            }else{
				return false;
            }
        }
        function addStudentTable(id,classNumber,studentNumber,name,score,duty) {
            $("#studentInfo tbody").append("  <tr class='odd'>\n" +
                "<td class=' sorting_1'>"+studentNumber+"</td>\n" +
                "<td class='center '>"+name+"</td>\n" +
                "<td class='center '>"+classNumber+"</td>\n" +
                "<td class='center '>"+duty+"</td>\n" +
                "<td class='center '>"+score+"</td>\n" +
                "<td class='center '>\n" +
                "<a id='scoreDatils"+id+"' class='btn btn-success' href=''>\n" +
                "<i class='icon-zoom-in icon-white'></i>  \n" +
                "操行详细                                            \n" +
                "</a>\n" +
                "<a id='updateStudent"+id+"' class='btn btn-info' href=''>\n" +
                "<i class='icon-edit icon-white'></i>  \n" +
                "编辑信息\n" +
                "</a>\n" +
                "<a id='delete"+id+"' class='btn btn-danger' href='javascript:void(0);' onclick='deleteStudent(id="+id+",this);'>\n" +
                "<i class='icon-trash icon-white'></i> \n" +
                "删除学生\n" +
                "</a>\n" +
                "<a id='addScore"+id+"' class='btn btn-info' href=''>\n" +
                "<i class='icon-edit icon-white'></i>  \n" +
                "添加操行\n" +
                "</a>\n" +
                "</td>\n" +
                "</tr>");

        }
	</script>
</head>

<body>
	<div class="container-fluid"
		style="padding-left:0px;padding-right:2px;">
		<div class="row-fluid">
			<div id="content" class="span10" style="width:100%;">
				<div class="row-fluid sortable">
					<div class="box span12">
						<div class="box-header well">
							<h2>
								<i class="icon-user"></i>学生列表
							</h2>
						</div>
						<div class="box-content">
							<div id="DataTables_Table_0_wrapper" class="dataTables_wrapper">
								
								<table
									class="table table-striped table-bordered bootstrap-datatable datatable dataTable"
									id="studentInfo">
									<thead>
										  <tr>
										  <th class="sorting_asc"  rowspan="1" colspan="1"  style="width: 130px;">学生学号</th>
										  <th class="sorting"  rowspan="1" colspan="1"  style="width: 90px;">学生姓名</th>
										  <th class="sorting"  rowspan="1" colspan="1"  style="width: 100px;">所在班级</th>
										  <th class="sorting"  rowspan="1" colspan="1"  style="width: 200px;">职位</th>
										  <th class="sorting"  rowspan="1" colspan="1" style="width: 83px;">操行总分</th>
										  <th class="sorting"  rowspan="1" colspan="1"  style="width: 439px;">操作</th>
										  </tr>
									 </thead>

									<tbody>
									
									</tbody>
								</table>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
</html>
